package ps.client.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import ps.client.gui.util.PsOverlayWindow;


@SuppressWarnings("serial")
public class OverlayWindow extends PsOverlayWindow {
    
    MessagePanel messagePanel;
    
    MainFrame mainFrame;
    
    public OverlayWindow(MainFrame mainFrame, String prefNode) {
        super(null, LEFT, prefNode);
        this.mainFrame = mainFrame;
        
        messagePanel = new MessagePanel(mainFrame);
        messagePanel.setTimeStamp(false);
        
        setMinimumSize(new Dimension(320, 80));
        
        contentPanel.add(messagePanel, BorderLayout.CENTER);
        
        buttonPanel.remove(configButton);
        
        biggerButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setSize(getSize().width + 20, getSize().height + 20);
            }
        });
        smallerButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setSize(getSize().width - 20, getSize().height - 20);
            }
        });
        clearButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                messagePanel.clearMessages();
            }
        });
    }
    
    @Override
    protected void loadSettings() {
        setSize(400, 160);
        setLocation(20, 20);
        super.loadSettings();
    }
    
    @Override
    public void setVisibility() {
        setVisible(getPrefNode().getBoolean(WINDOW_IS_VISIBLE, true));
    }
    
    public MessagePanel getMessagePanel() {
        return messagePanel;
    }

}
